import { createApp } from 'vue'
import './style.css' // 引入Tailwind CSS
import './assets/style/input.css'
import App from './App.vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from '@/router/index'
import permission from '@/permission/permission'
import { initTheme } from '@/utils/theme'
import { i18n } from '@/utils/i18n'
// 导入权限控制，确保动态路由加载
import '@/permission/index'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zh from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
import ja from 'element-plus/es/locale/lang/ja'

// 初始化主题
initTheme()

const app = createApp(App)
// 注册权限指令
app.directive('permission', permission)
app.use(router)
app.use(createPinia())
app.use(i18n)
app.use(ElementPlus, {
  locale: i18n.global.locale.value === 'zh' ? zh : i18n.global.locale.value === 'en' ? en : ja
})

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.mount('#app')